package com.myapp.mobilesafe.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by lijie on 2016/4/27.
 */
public class PrefUtils {
    public static void putBoolean(String key,Boolean values,Context ctx){
        SharedPreferences sp = ctx.getSharedPreferences("config",Context.MODE_PRIVATE);
        sp.edit().putBoolean(key,values).commit();
    }
    public static Boolean getBoolean(String key,Boolean defValue,Context ctx){
        SharedPreferences sp = ctx.getSharedPreferences("config",Context.MODE_PRIVATE);
       return sp.getBoolean(key,defValue);
    } public static void putString(String key,String values,Context ctx){
        SharedPreferences sp = ctx.getSharedPreferences("config",Context.MODE_PRIVATE);
        sp.edit().putString(key,values).commit();
    }
    public static String getString(String key,String defValue,Context ctx){
        SharedPreferences sp = ctx.getSharedPreferences("config",Context.MODE_PRIVATE);
       return sp.getString(key,defValue);
    } public static void putInt(String key,int values,Context ctx){
        SharedPreferences sp = ctx.getSharedPreferences("config",Context.MODE_PRIVATE);
        sp.edit().putInt(key,values).commit();
    }
    public static int getInt(String key,int defValue,Context ctx){
        SharedPreferences sp = ctx.getSharedPreferences("config",Context.MODE_PRIVATE);
       return sp.getInt(key,defValue);
    }
    public static void remove(String key,Context ctx){
        SharedPreferences sp = ctx.getSharedPreferences("config",Context.MODE_PRIVATE);
        sp.edit().remove(key).commit();
    }
}
